﻿Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms

Namespace Othello
    ''' <summary>
    ''' Summary description for StatisticsDialog.
    ''' </summary>
    Public Class StatisticsDialog
        Inherits System.Windows.Forms.Form
        Private overallGroupBox As System.Windows.Forms.GroupBox
        Private blackWinsTextLabel As System.Windows.Forms.Label
        Private blackWinsLabel As System.Windows.Forms.Label
        Private whiteWinsTextLabel As System.Windows.Forms.Label
        Private whiteWinsLabel As System.Windows.Forms.Label
        Private overallDrawTextLabel As System.Windows.Forms.Label
        Private overallDrawsLabel As System.Windows.Forms.Label
        Private overallTotalScoreTextLabel As System.Windows.Forms.Label
        Private blackTotalScoreTextLabel As System.Windows.Forms.Label
        Private blackTotalScoreLabel As System.Windows.Forms.Label
        Private whiteTotalScoreTextLabel As System.Windows.Forms.Label
        Private whiteTotalScoreLabel As System.Windows.Forms.Label
        Private WithEvents resetButton As System.Windows.Forms.Button
        Private closeButton As System.Windows.Forms.Button

        ''' <summary>
        ''' Required designer variable.
        ''' </summary>

        Private statistics As Statistics

        Public Sub New(ByVal statistics As Statistics)
            '
            ' Required for Windows Form Designer support
            '
            InitializeComponent()

            '
            ' TODO: Add any constructor code after InitializeComponent call
            '

            ' Create a copy of the given game statistics.
            Me.statistics = statistics

            ' Set the form controls based on those statistics.
            Me.MapStatisticsToControls()

            ' Activate the "Close" button.
            Me.closeButton.[Select]()
        End Sub

        ''' <summary>
        ''' Clean up any resources being used.
        ''' </summary>
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If components IsNot Nothing Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub

#Region "Windows Form Designer generated code"
        ''' <summary>
        ''' Required method for Designer support - do not modify
        ''' the contents of this method with the code editor.
        ''' </summary>
        Private Sub InitializeComponent()
            Me.components = New System.ComponentModel.Container
            Me.overallGroupBox = New System.Windows.Forms.GroupBox
            Me.whiteTotalScoreLabel = New System.Windows.Forms.Label
            Me.whiteTotalScoreTextLabel = New System.Windows.Forms.Label
            Me.blackTotalScoreLabel = New System.Windows.Forms.Label
            Me.blackTotalScoreTextLabel = New System.Windows.Forms.Label
            Me.overallTotalScoreTextLabel = New System.Windows.Forms.Label
            Me.overallDrawsLabel = New System.Windows.Forms.Label
            Me.overallDrawTextLabel = New System.Windows.Forms.Label
            Me.whiteWinsLabel = New System.Windows.Forms.Label
            Me.whiteWinsTextLabel = New System.Windows.Forms.Label
            Me.blackWinsLabel = New System.Windows.Forms.Label
            Me.blackWinsTextLabel = New System.Windows.Forms.Label
            Me.closeButton = New System.Windows.Forms.Button
            Me.resetButton = New System.Windows.Forms.Button
            Me.overallGroupBox.SuspendLayout()
            Me.SuspendLayout()
            '
            'overallGroupBox
            '
            Me.overallGroupBox.Controls.Add(Me.whiteTotalScoreLabel)
            Me.overallGroupBox.Controls.Add(Me.whiteTotalScoreTextLabel)
            Me.overallGroupBox.Controls.Add(Me.blackTotalScoreLabel)
            Me.overallGroupBox.Controls.Add(Me.blackTotalScoreTextLabel)
            Me.overallGroupBox.Controls.Add(Me.overallTotalScoreTextLabel)
            Me.overallGroupBox.Controls.Add(Me.overallDrawsLabel)
            Me.overallGroupBox.Controls.Add(Me.overallDrawTextLabel)
            Me.overallGroupBox.Controls.Add(Me.whiteWinsLabel)
            Me.overallGroupBox.Controls.Add(Me.whiteWinsTextLabel)
            Me.overallGroupBox.Controls.Add(Me.blackWinsLabel)
            Me.overallGroupBox.Controls.Add(Me.blackWinsTextLabel)
            Me.overallGroupBox.Location = New System.Drawing.Point(9, 8)
            Me.overallGroupBox.Name = "overallGroupBox"
            Me.overallGroupBox.Size = New System.Drawing.Size(271, 120)
            Me.overallGroupBox.TabIndex = 0
            Me.overallGroupBox.TabStop = False
            Me.overallGroupBox.Text = "Overall"
            '
            'whiteTotalScoreLabel
            '
            Me.whiteTotalScoreLabel.Location = New System.Drawing.Point(216, 68)
            Me.whiteTotalScoreLabel.Name = "whiteTotalScoreLabel"
            Me.whiteTotalScoreLabel.Size = New System.Drawing.Size(40, 13)
            Me.whiteTotalScoreLabel.TabIndex = 10
            Me.whiteTotalScoreLabel.Text = "0"
            Me.whiteTotalScoreLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
            '
            'whiteTotalScoreTextLabel
            '
            Me.whiteTotalScoreTextLabel.AutoSize = True
            Me.whiteTotalScoreTextLabel.Location = New System.Drawing.Point(170, 68)
            Me.whiteTotalScoreTextLabel.Name = "whiteTotalScoreTextLabel"
            Me.whiteTotalScoreTextLabel.Size = New System.Drawing.Size(38, 13)
            Me.whiteTotalScoreTextLabel.TabIndex = 9
            Me.whiteTotalScoreTextLabel.Text = "White:"
            '
            'blackTotalScoreLabel
            '
            Me.blackTotalScoreLabel.Location = New System.Drawing.Point(216, 42)
            Me.blackTotalScoreLabel.Name = "blackTotalScoreLabel"
            Me.blackTotalScoreLabel.Size = New System.Drawing.Size(40, 13)
            Me.blackTotalScoreLabel.TabIndex = 8
            Me.blackTotalScoreLabel.Text = "0"
            Me.blackTotalScoreLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
            '
            'blackTotalScoreTextLabel
            '
            Me.blackTotalScoreTextLabel.AutoSize = True
            Me.blackTotalScoreTextLabel.Location = New System.Drawing.Point(171, 42)
            Me.blackTotalScoreTextLabel.Name = "blackTotalScoreTextLabel"
            Me.blackTotalScoreTextLabel.Size = New System.Drawing.Size(37, 13)
            Me.blackTotalScoreTextLabel.TabIndex = 7
            Me.blackTotalScoreTextLabel.Text = "Black:"
            '
            'overallTotalScoreTextLabel
            '
            Me.overallTotalScoreTextLabel.AutoSize = True
            Me.overallTotalScoreTextLabel.Location = New System.Drawing.Point(141, 16)
            Me.overallTotalScoreTextLabel.Name = "overallTotalScoreTextLabel"
            Me.overallTotalScoreTextLabel.Size = New System.Drawing.Size(65, 13)
            Me.overallTotalScoreTextLabel.TabIndex = 6
            Me.overallTotalScoreTextLabel.Text = "Total Score:"
            '
            'overallDrawsLabel
            '
            Me.overallDrawsLabel.Location = New System.Drawing.Point(104, 94)
            Me.overallDrawsLabel.Name = "overallDrawsLabel"
            Me.overallDrawsLabel.Size = New System.Drawing.Size(24, 13)
            Me.overallDrawsLabel.TabIndex = 5
            Me.overallDrawsLabel.Text = "0"
            Me.overallDrawsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
            '
            'overallDrawTextLabel
            '
            Me.overallDrawTextLabel.AutoSize = True
            Me.overallDrawTextLabel.Location = New System.Drawing.Point(52, 94)
            Me.overallDrawTextLabel.Name = "overallDrawTextLabel"
            Me.overallDrawTextLabel.Size = New System.Drawing.Size(40, 13)
            Me.overallDrawTextLabel.TabIndex = 4
            Me.overallDrawTextLabel.Text = "Draws:"
            '
            'whiteWinsLabel
            '
            Me.whiteWinsLabel.Location = New System.Drawing.Point(104, 68)
            Me.whiteWinsLabel.Name = "whiteWinsLabel"
            Me.whiteWinsLabel.Size = New System.Drawing.Size(24, 13)
            Me.whiteWinsLabel.TabIndex = 3
            Me.whiteWinsLabel.Text = "0"
            Me.whiteWinsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
            '
            'whiteWinsTextLabel
            '
            Me.whiteWinsTextLabel.AutoSize = True
            Me.whiteWinsTextLabel.Location = New System.Drawing.Point(29, 68)
            Me.whiteWinsTextLabel.Name = "whiteWinsTextLabel"
            Me.whiteWinsTextLabel.Size = New System.Drawing.Size(62, 13)
            Me.whiteWinsTextLabel.TabIndex = 2
            Me.whiteWinsTextLabel.Text = "White wins:"
            '
            'blackWinsLabel
            '
            Me.blackWinsLabel.Location = New System.Drawing.Point(104, 42)
            Me.blackWinsLabel.Name = "blackWinsLabel"
            Me.blackWinsLabel.Size = New System.Drawing.Size(24, 13)
            Me.blackWinsLabel.TabIndex = 1
            Me.blackWinsLabel.Text = "0"
            Me.blackWinsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight
            '
            'blackWinsTextLabel
            '
            Me.blackWinsTextLabel.AutoSize = True
            Me.blackWinsTextLabel.Location = New System.Drawing.Point(30, 42)
            Me.blackWinsTextLabel.Name = "blackWinsTextLabel"
            Me.blackWinsTextLabel.Size = New System.Drawing.Size(61, 13)
            Me.blackWinsTextLabel.TabIndex = 0
            Me.blackWinsTextLabel.Text = "Black wins:"
            '
            'closeButton
            '
            Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.closeButton.Location = New System.Drawing.Point(205, 264)
            Me.closeButton.Name = "closeButton"
            Me.closeButton.Size = New System.Drawing.Size(75, 23)
            Me.closeButton.TabIndex = 3
            Me.closeButton.Text = "Close"
            '
            'resetButton
            '
            Me.resetButton.Location = New System.Drawing.Point(120, 264)
            Me.resetButton.Name = "resetButton"
            Me.resetButton.Size = New System.Drawing.Size(75, 23)
            Me.resetButton.TabIndex = 2
            Me.resetButton.Text = "Reset"
            '
            'StatisticsDialog
            '
            Me.AcceptButton = Me.closeButton
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.CancelButton = Me.closeButton
            Me.ClientSize = New System.Drawing.Size(290, 295)
            Me.ControlBox = False
            Me.Controls.Add(Me.resetButton)
            Me.Controls.Add(Me.closeButton)
            Me.Controls.Add(Me.overallGroupBox)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
            Me.MaximizeBox = False
            Me.MinimizeBox = False
            Me.Name = "StatisticsDialog"
            Me.ShowInTaskbar = False
            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
            Me.Text = "Statistics"
            Me.overallGroupBox.ResumeLayout(False)
            Me.overallGroupBox.PerformLayout()
            Me.ResumeLayout(False)

        End Sub
#End Region

        '
        ' Sets the form controls based on the current game statistics.
        '
        Public Sub MapStatisticsToControls()
            ' Get and display the game statistics.
            Me.blackWinsLabel.Text = Me.statistics.BlackWins.ToString()
            Me.whiteWinsLabel.Text = Me.statistics.WhiteWins.ToString()
            Me.overallDrawsLabel.Text = Me.statistics.OverallDraws.ToString()
            Me.blackTotalScoreLabel.Text = Me.statistics.BlackTotalScore.ToString()
            Me.whiteTotalScoreLabel.Text = Me.statistics.WhiteTotalScore.ToString()

            ' Redraw the display.
            Me.Refresh()
        End Sub

        ' ===================================================================
        ' Event handlers for the form buttons.
        ' ===================================================================

        '
        ' Resets the game statistics when the "Reset" button is clicked.
        '
        Private Sub resetButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles resetButton.Click
            ' Prompt for confirmation.
            Dim dlg As New ConfirmDialog("Reset statistics?")
            If dlg.ShowDialog(Me) = DialogResult.Yes Then
                ' Reset and display the statistics.
                Me.statistics.Reset()
                Me.MapStatisticsToControls()
            End If

            dlg.Dispose()
        End Sub
        Private components As System.ComponentModel.IContainer

        Private Sub StatisticsDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'OthelloDB.userTable' table. You can move, or remove it, as needed.

        End Sub
        Friend WithEvents IDDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
        Friend WithEvents UserNameDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
        Friend WithEvents PasswordDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
        Friend WithEvents WinsDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
        Friend WithEvents ScoreDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
    End Class
End Namespace
